package com.spring.sunflower.userinfo

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.Toolbar
import com.bumptech.glide.Glide
import com.spring.sunflower.R
import com.spring.sunflower.base.BaseCompatActivity

/**
 * Created by Kevin on 2021/8/16<br/>
 *
 * Describe:<br/>
 */
class AuthRealResultActivity : BaseCompatActivity() {
    private var ivCurrentAvatar: ImageView? = null
    private var ivAuthAvatar: ImageView? = null
    private var ivResult: ImageView? = null
    private var tvResult: TextView? = null
    private var tvDone: TextView? = null
    private var tvCancel: TextView? = null


    override fun initView() {
        tvTitle.text = "认证结果"
        val toolBar = findViewById<Toolbar>(R.id.toolBar)
        toolBar.setNavigationIcon(R.drawable.bg_shape_transparent)
        val intent = intent
        val authAvatar = intent.getStringExtra("authAvatar")
        val currentAvatar = intent.getStringExtra("currentAvatar")
        val result = intent.getBooleanExtra("authResult", false)
        ivCurrentAvatar = findViewById(R.id.ivCurrentAvatar)
        ivAuthAvatar = findViewById(R.id.ivAuthAvatar)
        ivResult = findViewById(R.id.ivResult)
        tvResult = findViewById(R.id.tvResult)
        tvDone = findViewById(R.id.tvDone)
        tvCancel = findViewById(R.id.tvCancel)
        Glide.with(this)
            .load(currentAvatar)
            .placeholder(R.drawable.ic_placeholder)
            .into(ivCurrentAvatar!!)
        Glide.with(this)
            .load(authAvatar)
            .placeholder(R.drawable.ic_placeholder)
            .into(ivAuthAvatar!!)
        tvResult!!.text = if (result) "当前头像已通过真人认证" else "当前头像未通过真人认证"
        tvResult!!.setTextColor(if (result) getColorX(R.color.teal_200) else getColorX(R.color.red_1))
        if (result) {
            tvDone!!.text = "完成认证"
            tvCancel!!.visibility = View.GONE
        } else {
            tvDone!!.text = "重新认证"
            tvCancel!!.visibility = View.VISIBLE
            tvCancel!!.text = "取消认证"

        }
        tvDone!!.setOnClickListener {
            if (result) {
//                val intent = Intent(this, AuthRealActivity::class.java)
                setResult(RESULT_OK)
                finish()
//                startNewActivity(AuthCenterActivity::class.java)
            } else {
//                startNewActivity(AuthRealActivity::class.java)
                finish()
//                onBackPressed()
            }
        }
        tvCancel!!.setOnClickListener {
//            startNewActivity(AuthCenterActivity::class.java)
//            finish()
            setResult(RESULT_OK)
            finish()
        }
    }

    override fun getLayoutID(): Int = R.layout.activity_auth_real_result
}